import { ref } from 'vue'
import { ReminderForm } from './types'
import { saveReminder } from '@/api/order'

const useReminderForm = () => {
  const form = ref<ReminderForm>({
    content: '',
    remindEmpType: [3],
  })
  const submitLoading = ref(false)

  const submit = async (orderIds: Array<string>) => {
    submitLoading.value = true
    const res = await saveReminder({ ...form.value, workIds: orderIds })
    submitLoading.value = false
    return res.data as { code: number; data: object; message: string; success: boolean }
  }

  const reset = () => {
    form.value.content = ''
    form.value.remindEmpType = [3]
  }

  return {
    form,
    submitLoading,
    reset,
    submit,
  }
}

export default useReminderForm
